package com.ch.home.testMapper;

import com.ch.home.bean.Message;
import com.ch.home.mapper.userMessageMapper.MessageMapper;
import com.github.pagehelper.PageHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;
import java.util.LinkedList;

/**
 * Created by CHEN on 2019/8/20.
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class testMessageMapper {

    @Autowired
    MessageMapper messageMapper;


    @Test
    public void testSend() {

        Message message = new Message( );
        Message message2 = new Message( );
        message.setSenderId(1);
        message.setReceiverId(5);
        message2.setSenderId(5);
        message2.setReceiverId(1);


        message.setTime(new Date( ));
        message.setStatus(1);
        message.setMessageContent("this is a content!");

        message2.setTime(new Date( ));
        message2.setStatus(1);
        message2.setMessageContent("this is a content!");
        System.out.println(message);
        int send=0;
        for (int i =0;i<10;i++){

            send= messageMapper.send(message);
            send= messageMapper.send(message2);
        }

        System.out.println(send);
    }

    @Test
    public void testRecieve() {
        Message message = new Message( );
        message.setReceiverId(5);
        message.setSenderId(1);
        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(2,5);
        LinkedList<Message> recieve = messageMapper.recieve(message);
        System.out.println(recieve );
    }



}
